package com.shihc.spring.transaction.controller;

import com.shihc.spring.transaction.model.User;
import com.shihc.spring.transaction.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by shihc on 2016/1/21.
 */
@Controller
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/save")
    @ResponseBody
    public User save() {
        User user = new User();
        user.setName("test1");
        user.setEmail("test1@tt.com");
        user = userService.saveUser(user);
        return user;
    }

    @RequestMapping("/delete")
    @ResponseBody
    public int delete(User user) {
        int i = userService.deleteUser(user);
        return i;
    }

    @RequestMapping("/deleteById")
    @ResponseBody
    public int deleteById(User user) {
        int i = userService.deleteUser2(user);
        return i;
    }
}